<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>右边</title>
    <link href="/css/index.css" rel="stylesheet" type="text/css" >
    <link href="/css/browwerQuery.css" rel="stylesheet" type="text/css" >
</head>
<body>
<div class="men">
    <div class="main_center">
        <div class="main_center_right">
            <form action="/action/userAction.php" method="post">
                <div class="main">
                    <div class="main_center_right">
                        <form action="/action/userAction.php" method="post">
                            <div class="main">
                                <div class="right">
                                    <ul class="biaoti">
                                        <li>图书编号</li>
                                        <li>图书名称</li>
                                        <li>出版社</li>
                                        <li>价格</li>
                                        <li>借阅状态</li>
                                        <li>操作</li>
                                    </ul>
                                    <?php
                                    //连接数据库
                                    try {
                                        $db = new PDO('mysql:dbname=books;host=127.0.0.1','root','123456');
                                        $result= $db->query('select * from book');
                                        $re=$result->fetchAll();
                                        if($re){
                                            foreach($re as $list){?>
                                                <ul class="shuju">
                                                    <li><?="$list[bookid]"; ?></li>
                                                    <li><?="$list[bookName]"; ?></li>
                                                    <li><?="$list[press]";?></li>
                                                    <li><?="$list[price]";?></li>
                                                    <li><?php
                                                        if("$list[status]" ==1){
                                                            echo "<span>已借阅</span>";
                                                        }else{
                                                            echo "<span>未借阅</span>";
                                                        }
                                                        ?>
                                                    </li>
                                                    <li>
                                                        <a href="#">修改</a>
                                                        <a href="#">删除</a>
                                                    </li>
                                                    <div style="clear: both;"></div>
                                                </ul>
                                                <?php
                                            }
                                        }else{
                                            echo "<script> alert('查询失败!'); location.href='../index.php';</script>";
                                        }

                                    } catch (PDOException $e) {
                                        echo 'Connection failed';
                                    }
                                    ?>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </form>
        </div>
        <div style="clear: both;"></div>
    </div>
</div>

</body>
</html>